/******************************************************************************
 * FILE NAME:
 *  tp_types.h
 *
 * DESCRIPTION:
 * This file contains the function declarations and MARCOS
 * of syslog project.
 *
 * DESIGN REFERENCE:
 *
 *
 * REVISION HISTORY   :
 * Date            Author               REASON
 * 06.08.2013      Thuan Nguyen         Creation
 * 08.08.2013		Trinh Lam			Add configuration for transport layer
 *
 * Copyright 2005, NET
 * ***************************************************************************/

#ifndef TP_TYPES_H_
#define TP_TYPES_H_

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<pthread.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<sys/types.h>
#include<string.h>
//#include <libxml/xmlreader.h>

#include"../../common/h/common_def.h"

#define SYSLOG_PORT_LISTEN 514
#define TRANSPORT_MESSEGE_MAX_LENGHT 2000

#define XML_PORT            1
#define XML_PROTOCOL        2
#define XML_PROTOCOL_TYPE   3
#define XML_TYPE            4
#define XML_PROTOCOL_UDP    0
#define XML_PROTOCOL_TCP    1

#define XML_PORT_STR            "PORT"
#define XML_PROTOCOL_STR        "PROTOCOL"
#define XML_PROTOCOL_TYPE_STR   "PROTOCOL_TYPE"
#define XML_TYPE_STR            "TYPE"
#define XML_PROTOCOL_UDP_STR    "UDP"
#define XML_PROTOCOL_TCP_STR    "TCP"
#define XML_MAX_SOCK			9
#define XML_MAX_AF				39
#define CONFIG_TRANSPORT_LAYER_PATH "./configure/transport.cf"

/*State of Item into linked-list*/
enum item_state_t{
	ITEM_STATE_INACTIVE = 0,
	ITEM_STATE_ACTIVE
};
enum thread_action_tasklist_types_t{
	OPEN_CONNECTION = 0,
	CLOSE_CONNECTION
};
enum thread_types_t{
	MASTER_THREAD_TYPE = 0,
	CONNECTION_THREAD_TYPE,
	LISTEN_THREAD_TYPE,
	SENDER_THREAD_TYPE
};

typedef struct thread_info_t{
	U8 thread_type;
	pthread_t   thread_key;
	void        *thread_func;
	U32 socket_id;
	struct sockaddr_in client_addr;
}thread_info_t;

typedef struct threads_transport_t{
	U8 state_thread;
	struct threads_transport_t *p_next_threads;
	struct threads_transport_t *p_prev_threads;
	struct thread_info_t data_thread;
}threads_transport_t;


typedef struct config_struct_t
{
    U32     port;
    U8    protocol_type;
    U8    protocol;
    U8    type;
}config_struct_t;
#endif

